<?php

class Base_Controller_Plugin_UrlRoute extends Zend_Controller_Plugin_Abstract
{

    public function routeStartup(Zend_Controller_Request_Abstract $request)
    {
        $hostPart = explode('.', $request->getHttpHost());
        
        if ($hostPart[0] != 'www' && count($hostPart) > 2) {
            Zend_Controller_Front::getInstance()
            ->setDefaultModule($hostPart[0])
            ->setControllerDirectory(
                MODULES_PATH .'/'. $hostPart[0] .'/controllers'
            );
        }
    }
}